******************************************************************************************************************************************
* Replication code (Stata) for Manger, Mark S. 2014. “The Economic Logic of Asian PTAs: The Role of Intra-Industry Trade.”
* Journal of East Asian Studies 14(2) 2014.
*
* version 5 February 2014
*
* Model (1)
*
use JEAS_Manger_EconLogic2014, clear
*
*
tobit d_tariff HIIT VIIT lnExports_MA5 importer_import_comp_MA5 lnBilatFdiFlow ///
	 if (exporter=="JPN" | exporter=="KOR"), ll(0) vce(bootstrap, reps(250) cluster(pairid) idcluster(newid) group(pairid) seed(123))
outreg using JEAS_Manger_EconLogic2014-results.txt, nolabel ctitle((1)) se coefastr replace addstat(Clusters, e(N_clust), log-likelihood, e(ll)) adec(0,3,3)
*
*
* Model (2)
tobit d_tariff viitLevel hiitLevel lnExports_MA5 importer_import_comp_MA5 lnBilatFdiFlow ///
	 if (exporter=="JPN" | exporter=="KOR"), ll(0) vce(bootstrap, reps(250) cluster(pairid) idcluster(newid) group(pairid) seed(123))
outreg using JEAS_Manger_EconLogic2014-results.txt, nolabel ctitle((2)) se coefastr append addstat(Clusters, e(N_clust), log-likelihood, e(ll)) adec(0,3,3)
*
* Model (3)
*
*
logit exclusion HIIT VIIT lnExports_MA5 importer_import_comp_MA5 if (importer=="JPN" | importer=="KOR") & logitsample==1, ///
	 vce(bootstrap, reps(250) cluster(pairid) idcluster(newid) group(pairid) seed(123))
outreg using JEAS_Manger_EconLogic2014-results.txt, nolabel ctitle((3)) se coefastr append addstat(Clusters, e(N_clust), log-likelihood, e(ll)) adec(0,3,3)
*
** Uncomment the folllowing to calculate the relative risk scores shown in figure 2
*foreach v in lnExports_MA5 importer_import_comp_MA5 {
*	qui summarize `v'
*	local start = r(mean)
*	local end = r(mean) + r(sd)
*	qui prvalue, x(`v' = `start') rest(mean) save
*		prvalue, x(`v' = `end') dif brief
*}
*
*foreach v in HIIT VIIT {
*	qui prvalue, x(`v' = 0) rest(mean) save
*		prvalue, x(`v' = 1) dif brief
*}
*
* Model (4)
logit exclusion viitLevel hiitLevel lnExports_MA5 importer_import_comp_MA5 ///
	 if (importer=="JPN" | importer=="KOR") & logitsample==1, vce(bootstrap, reps(250) cluster(pairid) idcluster(newid) group(pairid) seed(123))
outreg using JEAS_Manger_EconLogic2014-results.txt, nolabel ctitle((4)) se coefastr append addstat(Clusters, e(N_clust), log-likelihood, e(ll)) adec(0,3,3)
*
*
tobit d_tariff viitLevel hiitLevel lnExports_MA5 importer_import_comp_MA5 lnBilatFdiFlow ///
	 if (exporter=="JPN" | exporter=="KOR"), ll(0) vce(bootstrap, reps(250) cluster(pairid) idcluster(newid) group(pairid) seed(123))
*
*
margins if viitLevel > 0, at((p25) viitLevel) atmeans
margins if hiitLevel > 0, at((p25) hiitLevel) atmeans
*
* Uncomment this to run the robustness check in the web appendix: 
* include a dummy variable denoting a country in an IMF program
*
* tobit d_tariff HIIT VIIT lnExports_MA5 importer_import_comp_MA5 lnBilatFdiFlow ImfProg /// 
*	if (exporter=="JPN" | exporter=="KOR"), ll(0) vce(bootstrap, reps(250) cluster(pairid) idcluster(newid) group(pairid) seed(123))
******************************************************************************************************************************************